package com.zh.config.utils;


/**
 * 图片格式：bmp，jpg，png，tif，gif，pcx，tga，exif，fpx，svg，psd，cdr，pcd，dxf，ufo，eps，ai，
 * raw，wmf，webp，avif，apng
 * 视频格式：“avi”、“mp4”、“mov”、“wmv”、“flv”、“mpeg”、“webm”
 * 音频格式：mp3、wma、wav、mp3pro、asf、aac、vqf
 */
public class KnowledgeType {
    public static final String k_pdf = "pdf";
    public static final String k_wma = "wma";
    public static final String k_asf = "asf";
    public static final String k_aac = "aac";
    public static final String k_vqf = "vqf";
    public static final String k_mp3pro = "mp3pro";
    public static final String k_mp4 = "mp4";
    public static final String k_mpeg = "mpeg";
    public static final String k_webm = "webm";
    public static final String k_wmv = "wmv";
    public static final String k_txt = "txt";
    public static final String k_png = "png";
    public static final String k_tif = "tif";
    public static final String k_raw = "raw";
    public static final String k_pcx = "pcx";
    public static final String k_eps = "eps";
    public static final String k_dxf = "dxf";
    public static final String k_avif = "avif";
    public static final String k_webp = "webp";
    public static final String k_apng = "apng";
    public static final String k_ufo = "ufo";
    public static final String k_ai = "ai";
    public static final String k_wmf = "wmf";
    public static final String k_cdr = "cdr";
    public static final String k_pcd = "pcd";
    public static final String k_fpx = "fpx";
    public static final String k_psd = "psd";
    public static final String k_exif = "exif";
    public static final String k_tga = "tga";
    public static final String k_bmp = "bmp";
    public static final String k_gif = "gif";
    public static final String k_jpg = "jpg";
    public static final String k_jpeg = "jpeg";
    public static final String k_ppt = "ppt";
    public static final String k_pptx = "pptx";
    public static final String k_wps = "wps";
    public static final String k_doc = "doc";
    public static final String k_docx = "docx";
    public static final String k_xls = "xls";
    public static final String k_xlsx = "xlsx";
    public static final String k_zip = "zip";
    public static final String k_ara = "rar";
    public static final String k_tar = "tar";
    public static final String k_gz = "gz";
    public static final String k_7z = "7z";
    public static final String k_xmind = "xmind";
    public static final String k_svg = "svg";
    public static final String k_csv = "csv";
    public static final String k_note = "note";
    public static final String k_mp3 = "mp3";
    public static final String k_wav = "wav";
    public static final String k_mov = "mov";
    public static final String k_avi = "avi";
    public static final String k_flv = "flv";

    public static boolean isWordFile(String type) {
        return type.equalsIgnoreCase(k_pdf) || type.equalsIgnoreCase(k_txt) ||
                type.equalsIgnoreCase(k_ppt) || type.equalsIgnoreCase(k_pptx) ||
                type.equalsIgnoreCase(k_wps) || type.equalsIgnoreCase(k_doc) ||
                type.equalsIgnoreCase(k_docx) || type.equalsIgnoreCase(k_xls) ||
                type.equalsIgnoreCase(k_xlsx) || type.equalsIgnoreCase(k_xmind) ||
                type.equalsIgnoreCase(k_csv) || type.equalsIgnoreCase(k_note) ||
                type.equalsIgnoreCase(k_svg);
    }

    public static boolean isImage(String type) {
        return type.equalsIgnoreCase(k_jpeg) || type.equalsIgnoreCase(k_png) ||
                type.equalsIgnoreCase(k_bmp) || type.equalsIgnoreCase(k_gif) ||
                type.equalsIgnoreCase(k_pcx) || type.equalsIgnoreCase(k_tga) ||
                type.equalsIgnoreCase(k_exif) || type.equalsIgnoreCase(k_fpx) ||
                type.equalsIgnoreCase(k_psd) || type.equalsIgnoreCase(k_cdr) ||
                type.equalsIgnoreCase(k_pcd) || type.equalsIgnoreCase(k_dxf) ||
                type.equalsIgnoreCase(k_ufo) || type.equalsIgnoreCase(k_eps) ||
                type.equalsIgnoreCase(k_ai) || type.equalsIgnoreCase(k_raw) ||
                type.equalsIgnoreCase(k_wmf) || type.equalsIgnoreCase(k_webp) ||
                type.equalsIgnoreCase(k_avif) || type.equalsIgnoreCase(k_apng) ||
                type.equalsIgnoreCase(k_jpg) || type.equalsIgnoreCase(k_tif);
    }

    public static boolean isVideo(String type) {
        return type.equalsIgnoreCase(k_mp4) || type.equalsIgnoreCase(k_avi) ||
                type.equalsIgnoreCase(k_wmv) || type.equalsIgnoreCase(k_mpeg) ||
                type.equalsIgnoreCase(k_webm) || type.equalsIgnoreCase(k_mov) ||
                type.equalsIgnoreCase(k_flv);
    }

    public static boolean isZip(String type) {
        return type.equalsIgnoreCase(k_zip) || type.equalsIgnoreCase(k_ara) ||
                type.equalsIgnoreCase(k_tar) || type.equalsIgnoreCase(k_gz) ||
                type.equalsIgnoreCase(k_7z);
    }

    public static boolean isMusic(String type) {
        return type.equalsIgnoreCase(k_mp3) || type.equalsIgnoreCase(k_wav) ||
                type.equalsIgnoreCase(k_wma) || type.equalsIgnoreCase(k_mp3pro) ||
                type.equalsIgnoreCase(k_asf) || type.equalsIgnoreCase(k_aac) ||
                type.equalsIgnoreCase(k_vqf);
    }

    public static boolean isDownloadFile(String url) {
        if (url.contains(".")) {
            String uPath = url.substring(url.lastIndexOf(".") + 1);
            if (isImage(uPath) || isMusic(uPath) || isVideo(uPath) || isWordFile(uPath) || isZip(uPath)) {
                return true;
            } else if (uPath.equalsIgnoreCase("apk")) {
                return true;
            }
        }
        return false;
    }
}
